const Answer = require("../model/answer.model");

class AnswerService {
  // 获取答卷列表
  async getAnswerList(config, where) {
    const { count, rows } = await Answer.findAndCountAll({
      ...config,
      where,
      order: [["createdAt", "DESC"]],
    });
    return { total: count, list: rows.map((i) => i.dataValues) };
  }

  // 创建答卷
  async createAnswer(AnswerInfo) {
    const res = await Answer.create(AnswerInfo);
    return res.dataValues
  }

  // 批量彻底删除答卷
  async deleteAnswerList(where) {
    return await Answer.destroy({ where });
  }
}

module.exports = new AnswerService();
